package online.inote.modules.user.entity;

import java.io.Serializable;
import java.util.Date;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern;
import javax.validation.groups.Default;

import org.hibernate.validator.constraints.Range;

import lombok.Data;
import online.inote.common.data.rule.GlobalRule;
import online.inote.common.data.valid.ByteLength;
import online.inote.modules.user.valid.ValidSaveUser;
import online.inote.modules.user.valid.ValidUpdateUser;

/**
 * <p>
 * Desc: 
 * </p>
 *
 * @author XQF SUI
 * @created 2018年8月29日 下午10:01:18
 * @version 1.0
 */
@Data
public class UserEntity implements Serializable {

	private static final long serialVersionUID = 7101324203653375960L;

	@NotBlank(message = "ID不能为空", groups = ValidUpdateUser.class)
	private String id;
	@ByteLength(min = 2, max = 10, message = "姓名最长为10个字母, 5个汉字", groups = {ValidSaveUser.class, ValidUpdateUser.class})
	@Pattern(regexp = GlobalRule.USERNAME, message = "姓名格式不对", groups = Default.class)
	private String name;
	@Pattern(regexp = GlobalRule.EMAIL, message = "邮箱格式不对")
	private String email;
	@Pattern(regexp = GlobalRule.ADDRESS, message = "地址格式不对")
	private String address;
	@Range(min = 1,max = 99,message = "性别必须在[1~99]之间")
	private Integer age;
	@Past
	private Date birthDate;
}